#include<stdio.h>
#include<string.h>

/*c语言指针学习第16课：结构体嵌套*/

struct Message//先定义这个小的，然后在后续定义中才能使用
{
    char phone[12];
    char mail[100];
};

struct Student
{
    char name[100];
    int age;
    char gender;
    double height;
    struct Message msg;
};

int main()
{
    struct Student stu1;

    strcpy(stu1.name,"张三");
    stu1.age = 23;
    stu1.gender = 'M';
    stu1.height = 1.78;

    strcpy(stu1.msg.phone,"13519003789");//嵌套第二个结构体
    strcpy(stu1.msg.mail,"13519003789@163.com");

    printf("学生姓名为%s\n",stu1.name);
    printf("学生年龄为%d\n",stu1.age);
    printf("学生性别为%c\n",stu1.gender);
    printf("学生身高为%lf\n",stu1.height);
    printf("学生电话为%s\n",stu1.msg.phone);
    printf("学生邮箱为为%s\n",stu1.msg.mail);

    struct Student stu2 = {"李四",22,'F',1.64,{"17968570326","lisi666@outlook.com"}};//批量定义

    printf("\n学生姓名为%s\n",stu2.name);
    printf("学生年龄为%d\n",stu2.age);
    printf("学生性别为%c\n",stu2.gender);
    printf("学生身高为%lf\n",stu2.height);
    printf("学生电话为%s\n",stu2.msg.phone);
    printf("学生邮箱为为%s\n",stu2.msg.mail);

    return 0;
}